/*
https://codeforces.ml/contest/1367/problem/B
B. Even Array
*/ 
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
using namespace std;
const int maxn = 110;
int a[maxn];
int main()
{
	int t;
	scanf("%d",&t);
	while(t--)
	{
		int n;
		scanf("%d",&n);
		for(int i = 0;i<n;i++)
		{
			scanf("%d",&a[i]);
		}
		int cnt1,cnt2;
		cnt1=cnt2=0;
		for(int i = 0;i<n;i++)
		{
			if(a[i]%2==1&&i%2==0)
			{
				cnt1++;
			}
			if(a[i]%2==0&&i%2==1)
			{
				cnt2++;
			}
		}
		if(cnt1-cnt2)
		{
			printf("-1\n");
		}
		else printf("%d\n",cnt1);
	}
}

